package com.wlr.blog.article.controller;

import com.wlr.blog.util.common.aspect.LogAround;
import com.wlr.blog.util.common.dto.Result;
import com.wlr.blog.web.common.entity.ImgInfo;
import com.wlr.blog.web.common.service.AlbumService;
import com.wlr.blog.web.common.vo.AlbumVO;
import com.wlr.blog.web.common.vo.ImgInfoVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author lrwang
 * @version 1.0
 * @date 2022/11/18 11:24
 */
@RestController
@Slf4j
@Api("相册接口类")
@RequestMapping("/album")
public class AlbumController {
    @Autowired
    AlbumService albumService;

    @LogAround
    @ApiOperation(value = "获取相册列表")
    @GetMapping("/list")
    public Result<?> getAlbumList() {
        List<AlbumVO> albumVoList = albumService.getAlbumVoList();
        return Result.success(albumVoList);
    }

    @ApiOperation(value = "根据相册编号获取相册图片")
    @GetMapping("/{id}")
    public Result<ImgInfoVO> getPhotoById(@PathVariable Integer id) {
        ImgInfoVO photoById = albumService.getPhotoById(id);
        return Result.success(photoById);
    }

}
